Short Distance from Line to Origin

A theoretically important problem, which we will visit again, involves finding the shortest distance from from any line to the origin. We will look at this first in 2d with familiar line equations and then later in 2d with parametric notation. An advantage of parametric notation is that it can be extended more easily to multi-dimensions.

Given the line $y=mx+b$, and the origin point $(0,0)$, we can assume a point, $A$, on the line that is the shortest distance to the origin. From the distance formula, we know the distance from the origin to any point $(x,y)$ in the plane to be $distance=\sqrt{x^{2}+y^{2}}.$ If we substituted in the $y$ value that is the line (that is, instead of $y$ in the distance equation, use $mx+b$), it would be the distance to any point on the line. $$distance=\sqrt{x^{2}+(mx+b)^{2}}$$ Now we could take the derivative of that and set it to zero and solve for $x$ to get the $x$ parameter of the shortest distance, but with the root notation, that would be annoying. It is easier to notice that minimizing the part under the root is sufficient because $\sqrt{}$ is a monotonic increasing function. Consequently, we can minimize the squared function by setting its derivative to zero and solving for $x$. $$0=\frac{d(x^{2}+(mx+b)^{2}}{dx} =\frac{d\left(x^{2}+m^{2}x^{2}+2mbx+b^{2}\right)} {dx} =\frac{d\left((1+m^{2})x^{2}+2mbx+b^{2}\right)}{dx}$$ $$0=2(1+m^{2})x+2mb$$ $$x=\frac{-mb}{(1+m^{2)}}$$

Aside: You may see that once squared, the function is a parabola of the form $Ax^{2}+Bx+C$. You may also recall that the vertex of this parabola has the x-coordinate $-B/2A$ , where $A$ and $B$ are the indicated coefficients. In that case, this tiny bit of calculus could be avoided. $$A=(1+m^{2})\;\;B=2mb.$$

So the point that is closest to the origin is $$A=\left[\begin{array}{c} {\displaystyle \frac{-mb}{(1+m^{2})}}\\ m\left({\displaystyle \frac{-mb}{(1+m^{2})}}\right)+b \end{array}\right]$$ It is useful to redo this using the parametric 2d line equation and thereby generalizing it to 3d and then n-dimensions. However, we will defer that to the chapter on vectors.